using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace ExamServer.Service
{
    public interface IRepositoryBase<T>
    {
       //定义数据操作CURD
        /// <summary>
        /// 查询所有列表
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<T>> GetAllAsync();

        /// <summary>
        /// 根据条件表达式查询数据
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        Task<IEnumerable<T>> GetByConditionAsync(Expression<Func<T, bool>> expression);
        
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        void Creatre(T entity);
        
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        void Update(T entity);
        
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity"></param>
        void Delete(T entity);
        
        /// <summary>
        /// 保存操作同步到数据库
        /// </summary>
        /// <returns></returns>
        Task<bool> SaveAsync();
    }
}
